package com.service.impl;


import com.dao.UserDao;
import com.dao.BaseDao;
import com.dao.impl.UserDaoImpl;
import com.pojo.User;
import com.service.UserService;

/**
 * @author zxl
 * @create :2022/9/28
 */
//serviceimpl调用dao里面的方法得到结果并判断
public class UserServiceImpl extends BaseDao implements UserService {
   private UserDao userDao =new UserDaoImpl() {
   };

    @Override
    public User login(User user) {
        //调用dao底层根据用户名和密码查询的方法获得一个用户
        return userDao.selectByUserNameAndPassWord(user);
    }

    @Override
    public boolean register(User user) {
        //调用dao层执行新增 返回受影响行数 如果 > 0表示新增成功
        return userDao.insertUser(user) > 0;
    }

    @Override
    public User findExistsName(String username) {
        return userDao.selectByName(username);
    }
}
